package com.perfma.xtest.tool.word;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Objects;

/**
 * @author lumingfeng
 * @version v1.0 2018年08月30日 下午5:10
 **/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UserMeta {
    @ApiModelProperty(value = "用户ID", dataType = "Long")
    private Long uid;
    @ApiModelProperty(value = "用户头像的URL", dataType = "String")
    private String imgUrl;
    @ApiModelProperty(value = "用户昵称", dataType = "String")
    private String nickName;

    private Long bid;

    private Boolean isBusiness;

    @ApiModelProperty(value = "邮箱", dataType = "String")
    private String email;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof UserMeta)) return false;
        UserMeta userMeta = (UserMeta) o;
        return Objects.equals(uid, userMeta.uid) &&
                Objects.equals(imgUrl, userMeta.imgUrl) &&
                Objects.equals(nickName, userMeta.nickName);
    }

    @Override
    public int hashCode() {

        return Objects.hash(uid, imgUrl, nickName);
    }

    @Override
    public UserMeta clone() {
        UserMeta userMeta = UserMeta.builder().imgUrl(this.imgUrl).nickName(this.nickName).uid(this.uid).build();
        return userMeta;
    }

    @Override
    public String toString(){
        return this.getUid().toString();
    }

    public static void merge(List<UserMeta> originalList, List<UserMeta> currentList){
        if(CollectionUtil.isEmpty(currentList)){
            return;
        }
        for(UserMeta userMeta:currentList){
            if(!originalList.contains(userMeta)){
                originalList.add(userMeta);
            }
        }
    }
}
